<?php
/**
 * Created by PhpStorm.
 * User: Raymond
 * Date: 2020-03-05
 * Time: 09:15
 */
$p = $argv[1];
$b = $argv[2];
$s = isset($argv[3]) ? $argv[3] : 0;

//$f = $p - ( 1 - $p) / $b;

//$tmp = $s + (1 - $p);
//$f = (1 / $b) * ( ($p*$b - $tmp) / ($p*$s + $tmp) );

//echo $f . "\n";

$f = isset($argv[4]) ? $argv[4] : 0.5;

$avg = pow((1+$b*$f),$p) * pow(1-$s*$f,1-$p);

echo $f . "\n";
echo $avg . "\n";

$n = isset($argv[5]) ? $argv[5] : 4;
$profit = pow($avg,$n);
echo $profit . "\n";